package springboot_api.serviceimpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import springboot_api.dao.ApiDao;
import springboot_api.entity.ApiEntity;
import springboot_api.service.ApiService;

@Service
public class ApiServiceImpl implements ApiService{
	@Autowired
	private ApiDao apiDao;
	@Override
	public boolean insertApi(ApiEntity apiEntity) {
		boolean flag=false;
		try {
			apiDao.insert(apiEntity);
			flag=true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}
	@Override
	public ApiEntity[] select() {
		RestTemplate rt=new RestTemplate();
		String url = "http://localhost:8083/main/select";
		ApiEntity[] result = rt.getForObject(url, ApiEntity[].class);
		return result;
	}

}
